const scrollBehavior = (to, from, savedPosition) => {
  if (savedPosition) {
    // 如果有值直接返回
    return savedPosition;
  }

  const position = {};

  // 检测是否有哈希值
  if (to.hash) {
    position.selector = to.hash;
  }

  // 是否回到顶部
  if (to.matched.some(m => m.meta.scrollToTop)) {
    position.x = 0;
    position.y = 0;
  }
  return position;
};

export default scrollBehavior;
